package com.oa.modules.approvalsec1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oa.common.utils.AppUtils;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.Query;
import com.oa.modules.approvalsec1.entity.EngineerConstruct;
import com.oa.modules.approvalsec1.dao.EngineerConstructDao;
import com.oa.modules.approvalsec1.service.EngineerConstructService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (EngineerConstruct)表服务实现类
 *
 * @author makejava
 * @since 2020-11-18 10:11:27
 */
@Service("engineerConstructService")
public class EngineerConstructServiceImpl extends ServiceImpl<EngineerConstructDao,EngineerConstruct> implements EngineerConstructService {
    @Resource
    private EngineerConstructDao engineerConstructDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public EngineerConstruct queryById(Long id) {
        return this.engineerConstructDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<EngineerConstruct> queryAllByLimit(int offset, int limit) {
        return this.engineerConstructDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param engineerConstruct 实例对象
     * @return 实例对象
     */
    @Override
    public EngineerConstruct insert(EngineerConstruct engineerConstruct) {
        this.engineerConstructDao.insert(engineerConstruct);
        return engineerConstruct;
    }

    /**
     * 修改数据
     *
     * @param engineerConstruct 实例对象
     * @return 实例对象
     */
    @Override
    public EngineerConstruct update(EngineerConstruct engineerConstruct) {
        this.engineerConstructDao.update(engineerConstruct);
        return this.queryById(engineerConstruct.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.engineerConstructDao.deleteById(id) > 0;
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        return new PageUtils(this.page(new Query<EngineerConstruct>().getPage(params), AppUtils.setQueryWrapper(new QueryWrapper<EngineerConstruct>(), AppUtils.checkMap(params), "id", false)));
    }

    @Override
    public List<EngineerConstruct> queryAll(EngineerConstruct engineerConstruct) {
        return engineerConstructDao.queryAll(engineerConstruct);
    }
}
